package twel.probenprophet.domain.rules.magic.decorators;

import twel.probenprophet.domain.rules.magic.CastableSpell;

public class SpellWithReducedCosts extends SpontaneousModificationDecorator {

	public SpellWithReducedCosts(CastableSpell decorated) {
		super(decorated);
	}

	public SpellWithReducedCosts(CastableSpell decorated, int times) {
		super(decorated, times);
	}

	@Override
	public int getAstralEnergyCost() {
		int astralEnergyCost = getDecorated().getAstralEnergyCost();
		float modifier = 1 - 0.1f * getTimes();
		int roundedCost = Math.round(astralEnergyCost * modifier);
		int reducedCost = Math.min(roundedCost, astralEnergyCost - getTimes());

		return Math.max(reducedCost, 1);
	}

	@Override
	protected Integer getSpellSkillModifier() {
		return 3;
	}

	@Override
	public int getCastTime() {
		return getTimes() + getDecorated().getCastTime();
	}
}
